package com.lt.contract.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.lt.contract.entity.NmDeptStaff;
import com.lt.contract.entity.NmRole;
import com.lt.contract.service.NmDeptStaffService;
import com.lt.contract.service.NmRoleService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 权限控制(NmRole)表控制层
 *
 * @author makejava
 * @since 2020-04-07 22:10:56
 */
@RestController
@RequestMapping("nmRole")
public class NmRoleController {
    /**
     * 服务对象
     */
    @Resource
    private NmRoleService nmRoleService;

    @Resource
    private NmDeptStaffService nmDeptStaffService;

    public  String getRole(String params){
        JSONObject jsonObject = JSON.parseObject(params);
        if(jsonObject.containsKey("staffId")){
            NmRole nmRole = nmRoleService.queryById(jsonObject.getString("staffId"));
            NmDeptStaff staffId = nmDeptStaffService.queryById(jsonObject.getString("staffId"));
            jsonObject.put("role",nmRole.getRoleType());
            jsonObject.put("departIdR",staffId.getDeptId());
            params = jsonObject.toJSONString();
        }
        return params;
    }

}
